﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="/lib/css/layout-default-latest.css" />
    <link rel="stylesheet" type="text/css" href="/lib/css/themes/base/jquery.ui.all.css" />
    <link href="/lib/css/StyleSheet1.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="/plugins/slick.grid.css" type="text/css" />
    <link rel="stylesheet" href="/lib/css/jquery.jdMenu.css" type="text/css" />
    <link href="/plugins/CheckList/ui.dropdownchecklist.themeroller.css" rel="stylesheet"
        type="text/css" />
    <style type="text/css">
        /* remove padding and scrolling from elements that contain an Accordion OR a content-div */
        .ui-layout-center, /* has content-div */ .ui-layout-west, /* has Accordion */ .ui-layout-east, /* has content-div ... */ .ui-layout-east .ui-layout-content
        {
            /* content-div has Accordion */
            padding: 0;
            overflow: hidden;
        }
        .ui-layout-center P.ui-layout-content
        {
            line-height: 1.4em;
            margin: 0; /* remove top/bottom margins from <P> used as content-div */
        }
        h3, h4
        {
            /* Headers & Footer in Center & East panes */
            font-size: 1.1em;
            background: #EEF;
            border: 1px solid #BBB;
            border-width: 0 0 1px;
            padding: 7px 10px;
            margin: 0;
        }
        .ui-layout-east h4
        {
            /* Footer in East-pane */
            font-size: 0.9em;
            font-weight: normal;
            border-width: 1px 0 0;
        }
        .menuContainerJSListBox
        {
            margin-left: 50px;
            margin-right: 50px;
            margin-bottom: 50px;
            overflow: auto;
        }
        .DCTextClass
        {
            margin-top: 10px;
            margin-left: 50px;
            margin-right: 50px;
            margin-bottom: 20px;
        }
        #loadingScreen
        {
            background: url(../images/ajax-loader.gif) no-repeat 5px 8px;
            padding-left: 25px;
        }
        .NDPriceCss
        {
            background-color: greenyellow;
        }
        .highlightPriceApporver1
        {
            background-color: yellow;
            height: 25px;
        }
        .highlightPriceApporver2
        {
            background-color: orange;
            height: 25px;
        }
        .highlightPriceApporver3
        {
            background-color: red;
            height: 25px;
        }
    </style>
    <!-- REQUIRED scripts for layout widget -->
    <script src="/lib/js/jquery-latest.js" type="text/javascript"></script>
    <script src="/lib/js/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="/lib/js/jquery.layout-latest.js"></script>
    <script type="text/javascript" src="/lib/js/jquery.layout.resizePaneAccordions-1.0.js"></script>
    <script src="/plugins/globalize.js" type="text/javascript"></script>
    <script type="text/javascript" src="/lib/js/themeswitchertool.js"></script>
    <script type="text/javascript" src="/lib/js/debug.js"></script>
    <script type="text/javascript" src="/lib/js/jquery.dimensions.js"></script>
    <script type="text/javascript" src="/lib/js/jquery.positionBy.js"></script>
    <script type="text/javascript" src="/lib/js/jquery.bgiframe.js"></script>
    <script type="text/javascript" src="/lib/js/jquery.jdMenu.js"></script>
    <script src="/lib/js/jquery.event.drag-2.0.min.js"></script>
    <script src="/plugins/slick.editors.js"></script>
    <script src="/plugins/slick.core.js"></script>
    <script src="/plugins/slick.checkboxselectcolumn.js"></script>
    <script src="/plugins/slick.autotooltips.js"></script>
    <script src="/plugins/slick.cellrangedecorator.js"></script>
    <script src="/plugins/slick.cellrangeselector.js"></script>
    <script src="/plugins/slick.cellcopymanager.js"></script>
    <script src="/plugins/slick.cellselectionmodel.js"></script>
    <script src="/plugins/slick.rowselectionmodel.js"></script>
    <script src="/plugins/slick.formatters.js"></script>
    <script src="/plugins/slick.grid.js"></script>
    <script src="/plugins/surge.core.js" type="text/javascript"></script>
    <script src="/plugins/surge.slickGrid.js" type="text/javascript"></script>
    <script src="/Scripts/AjaxLoading.js" type="text/javascript"></script>
    <script src="/Scripts/Helper.js" type="text/javascript"></script>
    <script src="/Scripts/CurrentTime.js" type="text/javascript"></script>
    <script src="/Scripts/validation.js" type="text/javascript"></script>
    <script type="text/javascript">
         window.onload = DisplayTime;
        var myLayout;
        var mysupLayout;
        $(document).ready(function () {

            var rolename = $.cookie("userrole");
            if (rolename == null || rolename != 'Admin') {
                 window.location = '/Page/login.aspx';
            }

            myLayout = $('body').layout({
                west__size: 234
                , east__size: 300
                // RESIZE Accordion widget when panes resize
                , west__onresize: $.layout.callbacks.resizePaneAccordions
                , east__onresize: $.layout.callbacks.resizePaneAccordions
                , west__initClosed:true
            });

//            mysupLayout = $('#mainFrame').layout({
//                center__paneSelector: ".inner-center"
//                , south__size: '90%'
//            });

            $('ul.dropdown').jdMenu();
            // ACCORDION - in the West pane
            $("#accordion1").accordion({ fillSpace: true });

            // ACCORDION - in the East pane - in a 'content-div'
            $("#accordion2").accordion({
                fillSpace: true
                , active: 1
            });


            // THEME SWITCHER
            addThemeSwitcher('.ui-layout-north', { top: '12px', right: '5px' });
            // if a new theme is applied, it could change the height of some content,
            // so call resizeAll to 'correct' any header/footer heights affected
            // NOTE: this is only necessary because we are changing CSS *AFTER LOADING* using themeSwitcher
            setTimeout(myLayout.resizeAll, 1000); /* allow time for browser to re-render with new theme */




        });
        function loadFrm(url) {

            $.get(url, function (content) {

                $('#mainFrame').html(content);

            });
        }
       
        var ndhelp = new Helper();
        var columnNDPriceGrid = [];
        var gridNDPrice;
        function getColumn(parameters) {

            columnNDPriceGrid.push({ id: 'mprodh_grpname', name: '', field: 'mprodh_grpname'
            });
            columnNDPriceGrid.push({ id: 'PrevNDPrice', name: 'Prev NDPrice', field: 'olddiscountPrice'
            });
            columnNDPriceGrid.push({ id: 'NDPrice', name: 'NDPrice', field: 'discountPrice', formatter: Slick.Formatters.NDDiff, editor: Slick.Editors.Integer
            });

        }
        var optionsNDprice = {
            editable: true,
            enableRowReordering: true,
            enableCellNavigation: true,
            asyncEditorLoading: false,
            autoEdit: true
        };
        function getLastNDPrice(parameters) {
            ndhelp.GetLastestNDPrice(function (data) {

            });
        }
        
        function refreshNDPriceGrid(parameters) {
            ndhelp.GetLastestNDPrice(function (ndPricedata) {
                gridNDPrice = new Slick.Grid("#NDPriceGrid", ndPricedata.RMember, columnNDPriceGrid, optionsNDprice);
                gridNDPrice.setSelectionModel(new Slick.RowSelectionModel({ selectActiveRow: true }));

            });

            ndhelp.getLastestNdPriceItemJson(function(ndPriceItemLastest) {
                if (ndPriceItemLastest.RNdPrice != null)  {
                    $('#txtValidOn').val(ndPriceItemLastest.RNdPrice[0].ValidON);
                    $('#txtValidTo').val(ndPriceItemLastest.RNdPrice[0].ValidTO);
                    $('#remark').val(ndPriceItemLastest.RNdPrice[0].remark);
                    $('#remark2').val(ndPriceItemLastest.RNdPrice[0].remark2);
                }
                
            });
        }
        $(function () {
            getColumn();
            refreshNDPriceGrid();

            //Init button
            $("#btnSave")
                .button({
                 
                    icons: {
                        primary: "ui-icon-save"
                    }
                })
                .click(function () {
                    
                    var valid = true;
			        var validon = $.datepicker.formatDate('yy-mm-dd', $('#txtValidOn').datepicker('getDate'));
			    
			        var validto = $.datepicker.formatDate('yy-mm-dd', $('#txtValidTo').datepicker('getDate'));

			        valid = valid && IsNull(validon);
			        valid = valid && IsNull(validto);
			        
			        if (valid) {
			            var remark = $('#remark').val();
                        var remark2 = $('#remark2').val();
                        var datas = gridNDPrice.getData();
                        var data = { remark: remark,
                            remark2: remark2,
                            data: datas,
                            ValidOn: validon,
			                ValidTo: validto};
                        ndhelp.InserNDPrice(data, function(result) {
                            if (result != '-1') {
                                MsgBox('Update ' + result + ' records success');
                            }
                            else {
                                MsgBox("Cannot update data, Please delete duplicate ND price record");
                            }
                        });
			        }
			        else {
			            var top = ($(window).height() - 250) / 2;
			            var left = ($(window).width() - 350) / 2;
			            var message = 'Please select Valid ON and Valid To date.';
			            $('#dialogMessageID').text(message);
			            $("#dialog-message").dialog("open");
			            $(".Dialog").css('left', left);
			            $(".Dialog").css('top', top);
			        }
                    
                    //alert(datas);
                });
           
            $("#btnImport")
                .button({
                 
                    icons: {
                        primary: "ui-icon-save"
                    }
                })
                .click(function () {
			       OpenImportPopup();
                });
           $("#txtValidOn").datepicker({dateFormat: 'yy-mm-dd'});
                var today = new Date();
                //$("#txtValidOn").datepicker("option", "minDate", today );
                $("#txtValidTo").datepicker({dateFormat: 'yy-mm-dd'});
                $("#txtValidOn").change(function() {
                    var test = $(this).datepicker('getDate');
                    //var testm = new Date(test.getTime());
                   // var testm.setDate(testm.getDate() + 1);
                    //$("#endDate").datepicker("option", "minDate", testm);
                    $("#txtValidTo").datepicker("option", "minDate", test );
                });
        });
         $("#dialog-message" ).dialog({
            autoOpen: false,
			resizable: false,
			height:120,
            dialogClass: "Dialog",
			modal: true,
			buttons: {
				Ok: function() {
					$( this ).dialog( "close" );
				}
			}
		    });
    </script>
</head>
<body>
    <div class="ui-layout-north ui-widget-content" style="display: none;">
        <div id="main_header">
            <div class="logo" style="float: left; margin-top: 10px;">
                <img src="/images/logoNawa.png" alt="Nawaplastic Co.,Ltd." />
            </div>
            <div style="float: left; margin-top: 10px; margin-left: 100px;">
                <span style="font-family: verdana; font-size: 16px; font-weight: bold;" class="ui-state-highlight"
                    id="curTime"></span>
            </div>
            <div style="float: right; margin-right: 160px;">
                <div>
                    <div style="width: 70px; float: left">
                        User as:
                    </div>
                    <span class="userInfo" id="userNameShow">UserName</span><br />
                    <div style="width: 70px; float: left">
                        Logged in as:</div>
                    <span class="userInfo" id="SpanUserIP">IP</span>
                    <br />
                    <div style="width: 70px; float: left">
                        Role as :</div>
                    <span class="userInfo" id="SpanRoleShow">Role</span>
                </div>
            </div>
        </div>
        <div id="toolbarHolder">
            <div class="ui-state-default ui-corner-all ui-helper-clearfix">
                <ul id="main-menu" class="jd_menu dropdown ui-widget-header" onmouseover="myLayout.allowOverflow('north')"
                    onmouseout="myLayout.resetOverflow(this)">
                    <li><a href="#">Application &raquo;</a>
                        <ul class="ui-state-default">
                            <li><a href="/Page/AdminDocumentPage.htm">Admin Document Management</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Admin Tools&raquo;</a>
                        <ul class="ui-state-default">
                            <li><a href="/Page/adminMain.htm">UserRole Management</a></li>
                            <li><a href="/Page/ndpriceManament.htm">ND Price Management</a></li>
                            <li><a href="/Page/SaleApprovalMapping.htm">Sale and Approver Mapping</a></li>
                            <li><a href="/Page/SaleCoordinatorMapping.htm">Sale and SaleCo Mapping</a></li>
                            <li><a href="/Page/ProductGrpManament.htm">Product Cate Management</a></li>
                            <li><a href="/Page/ApprovalManagement.htm">Approval Management</a></li>
                            <li><a target="blank" href="/Page/ReportViewer.aspx">Report</a></li>
                            <li><a target="blank" href="/Page/ImportPipePriceBath.aspx">Import Pipe price convert</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div id="MessageBar" class="ui-layout-south ui-widget-content ui-state-error" style="display: none;">
        Message Bar
    </div>
    <div id="mainFrame" class="ui-layout-center" width="100%" height="600" frameborder="0"
        scrolling="auto">
        <div style="height: 20px;">
        </div>
        <div class="ui-layout-south">
            <div style="padding-top: 10px; padding-bottom: 30px; padding-left: 10px; padding-right: 10px;">
                <span id="Span1" class=" ui-corner-all" style="float: left">Valid On
                    <input id="txtValidOn" type="text" />
                    valid To
                    <input id="txtValidTo" type="text" />
                </span>
            </div>
            <div id="NDPriceGrid" style="width: 50%; height: 270px; margin-bottom: 20px; padding-left: 10px;">
            </div>
            <div>
                <div style="margin: 5px; vertical-align: middle;">
                    <div style="width: 60px; float: left;">
                        Remark:
                    </div>
                    <input id="remark" type="text" />
                </div>
                <div style="margin: 5px; vertical-align: middle;">
                    <div style="width: 60px; float: left;">
                        Remark2:
                    </div>
                    <input id="remark2" type="text" /></div>
            </div>
            <div>
                <button id="btnImport">
                    Import ND Price</button>
                <button id="btnSave">
                    Save</button>
            </div>
        </div>
    </div>
    <div class="ui-layout-west" style="display: none;">
        <h3 class="ui-widget-header">
            Navigation</h3>
        <div class="ui-layout-content">
            <div id="accordion1" class="basic">
                <h3>
                    <a href="#">Section 1</a></h3>
                <div>
                </div>
            </div>
        </div>
    </div>
       <div id="dialog-message" title="Information!">
        <p style="margin-top: 12px;">
            <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;">
            </span>
            <div id="dialogMessageID">
            </div>
        </p>
    </div>
    <div id="loadingScreen" style="vertical-align: middle; text-align: center">
    </div>
</body>
</html>
